/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package practice.array;

import java.util.Scanner;

/**
 *
 * @author VANDH
 */
public class HotelManager1 {

    int count;
    String[] hotelName;
    String[] ownerName;
    String[] location;
    double[] tariff;

    public HotelManager1() {
        hotelName = new String[10];
        ownerName = new String[10];
        location = new String[10];
        tariff = new double[10];
    }

    public void inputHotels() {
        System.out.printf("Bao nhiêu khách sạn :");

        Scanner keyboard = new Scanner(System.in);
        count = keyboard.nextInt();

        if (count > 0 && count <= 10) {
            for (int i = 0; i < count; i++) {
                keyboard.nextLine();    // xóa dấu \n do nextInt() để lại
                System.out.println("Nhập khách sạn thứ : " + (i + 1));
                System.out.printf("Hotel name : ");
                hotelName[i] = keyboard.nextLine();
                System.out.printf("Owner name : ");
                ownerName[i] = keyboard.nextLine();
                System.out.printf("Location : ");
                location[i] = keyboard.nextLine();
                System.out.printf("Tariff : ");
                tariff[i] = keyboard.nextDouble();
            }
        } else {
            System.out.println("Số lượng không hợp lệ");
        }
    }

    public void showHotels() {
        for (int i = 0; i < count; i++) {
            System.out.println(
                    hotelName[i] + ", " + ownerName[i]
                    + ", " + location[i] + ", " + tariff[i]);
        }
    }

    public void findHotel() {
        System.out.printf("Owner name : ");
        Scanner keyboard = new Scanner(System.in);
        String owner = keyboard.nextLine();

        for (int i = 0; i < count; i++) {
            if (ownerName[i].equals(owner)) {
                System.out.println(
                        hotelName[i] + ", " + ownerName[i]
                        + ", " + location[i] + ", " + tariff[i]);
            }
        }
    }
}
